package com.aaa.mythread2;

public class MyThread3 {
    public static void main(String[] args) {
        // t1 执行完之后再执行t2

    Thread thread =  new Thread(new Runnable() {
        @Override
        public void run() {
            for (int i =0;i<30;i++){
                System.out.println(Thread.currentThread().getName()+",对应的i的值是:"+i);
            }
        }
    },"t1");


        Thread thread2 =  new Thread(new Runnable() {
            @Override
            public void run() {
                //
                try {
                    thread.join();// thread2  t1 运行结束之后  t2 开始运行
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }

                for (int i =0;i<30;i++){
                    System.out.println(Thread.currentThread().getName()+",对应的i的值是:"+i);
                }
            }
        },"t2");


        thread2.start();
        thread.start();
    }
}
